var ws = require('nodejs-websocket');

ws.createServer(function (conn) {
  conn.sendText('111')
  conn.on('text', function (str) {
    console.log('浏览器给服务端的信息为:' + str)
    conn.sendText(str)
  })
  conn.on('close', function (code, reason) {
    console.log('关闭连接', code, reason)
  });
  conn.on('error', function (code, reason) {
    console.log('异常关闭', code, reason)
  });
}).listen(9000)